<script type="text/javascript">
//会员组名称
$("input[name='title']").blur(function(){
    if($(this).val().length < 2){
        $('#title_tips').html('<i class="fa fa-info-circle fa-lg mr-2"></i>{:lang('u_parameter_error')}');
    }else{
        $('#title_tips').html('');
    }
});
//会员组类型
$("input[name='is_admin']").click(function(){
    if($(this).val() != '1'){
        $('#rule_value').addClass('d-none');
    }else{
        $('#rule_value').removeClass('d-none');
    } 
});
//升级方式
$("input[name='upgrade[]']").click(function(){
    var upgrade = '';
    $("input[name='upgrade[]']:checked").each(function(i){
        upgrade += $(this).val() + ',';
    });
    upgrade = upgrade.substring(0,upgrade.length-1);
    upgrade_arr = upgrade.split(',');
    if(upgrade_arr.includes('0')){
        $('.upgrade_0').removeClass('d-none');
        $('#upgrade_tips').html('');
    }else{
        $('.upgrade_0').addClass('d-none');
    }
    if(upgrade_arr.includes('1')){
        $('.upgrade_1').removeClass('d-none');
        $('#upgrade_tips').html('');
    }else{
        $('.upgrade_1').addClass('d-none');
    }
    if(upgrade == '' || upgrade == 'undefined'){
        $('#close_time').addClass('d-none');
    }else{
        $('#close_time').removeClass('d-none');
    }
});
//升级方式：格式判断
function upgrade_vad(el,el_tips,length,max_val,method){
    var val = $(el).val();
    if(method == 'price'){
        var preg = /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/;
    }else{
        var preg = /^(0|[1-9][0-9]*)$/;
    }
    if(!preg.test(val) || val.length > length || val > max_val){
        $(el_tips).html('<i class="fa fa-info-circle fa-lg mr-2"></i>{:lang('u_parameter_error')}');
    }else{
        $(el_tips).html('');
    }
    //三级分销：佣金比例之和不能大于100
    switch (el) {
        case '#level_1':
        case '#level_2':
        case '#level_3':
            var total_rate = parseFloat($('#level_1').val()) + parseFloat($('#level_2').val()) + parseFloat($('#level_3').val());
            if(total_rate > 100){
                $(el_tips).html('<i class="fa fa-info-circle fa-lg mr-2"></i>{:lang('g_can_not_morethan_hundred')}');
            }else{
                $('#level_1').html('');$('#level_2').html('');$('#level_3').html('');
            }
            break; 
    }
}
//权限值
$(function(){
    {empty name="rs.id"}
        var url = "{:url('/authGroup/getrule',['lang'=>$lang])}";
    {else /}
        var url = "{:url('/authGroup/getrule',['lang'=>$lang])}"+"&id="+{$rs.id};
    {/empty}
    $.ajax({
        url: url,
        type: "get",
        dataType : "html",//数据格式 
        success: function(data){
            $("#getrule").html(data);
        }
    });
});
</script>